package util;

import java.awt.image.BufferedImage;
import java.io.File;
import java.util.TreeMap;
import javax.imageio.ImageIO;

public class Bitmap {
    
    private static final String filePath = "imgs/";
    public int w;
    public int h;
    public int wi;
    public int hi;
    public int nPixels;
    public int[] pixels;
    private TreeMap<Integer, Integer[]> map;
    
    public Bitmap(String filename) {
        try {
            BufferedImage img = ImageIO.read(new File(filePath + filename + ".png"));
            w = img.getWidth();
            h = img.getHeight();
            wi = w - 1;
            hi = h - 1;
            nPixels = w * h;
            pixels = new int[nPixels];
            img.getRGB(0, 0, w, h, pixels, 0, w);
            for (int i = 0; i < nPixels; i++) {
                int argb = pixels[i];
                int r = argb >> 16 & 0xFF;
                int g = argb >> 8 & 0xFF;
                int b = argb & 0xFF;
                if (r == 255 && g == 0 && b == 255) {
                    pixels[i] = Color.getColorRGBAi(0, 0, 0, 0);
                }
            }
        } catch (Exception e) {
            System.out.println(e);
            System.exit(0);
        }
    }
    
    public Bitmap(int width, int height, int[] imgPixels) {
        w = width;
        h = height;
        wi = w - 1;
        hi = h - 1;
        nPixels = w * h;
        pixels = imgPixels;
    }
    
//    public void genMipmaps() {
//        if (w % 2 == 0) {
//            int nextDim = w / 2;
//            Bitmap 
//        }
//    }
    
}